home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / ConvertToGrey.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  2.6 KB  |  105 lines

  1. /*
  2. ** $VER: ConvertToGrey.ieb 1.12, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 27/1 1997 Stockholm/Sweden
  6. **
  7. ** Make the image grey. (2:4:1 weighting)
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   'IE_TO_FRONT'
  42.  
  43.   'REQUEST' '"The ConvertToGrey batch script does not have any settings."' '" OK "'
  44.  
  45.   back = 'OK'
  46. return back
  47.  
  48. /* Required "Process_image" procedure  ------------------------------- */
  49.  
  50. process_image:
  51.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  52.   parse var options command
  53.  
  54.   'OPEN' '"'src_image'"' '24'
  55.   if (RC ~= 0) then do
  56.     'IE_TO_FRONT'
  57.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  58.     return '<ERROR>'
  59.   end
  60.   else LoadImage = result
  61.  
  62.   'CONVERT_TO_GREY' LoadImage
  63.   GreyImage = result
  64.   'CLOSE' LoadImage
  65.  
  66.   if left(getclip('cfg_save_frmt'),4)~='ILBM' then do
  67.     'CONVERT_TO_COLOUR' GreyImage
  68.     OutputImage = result
  69.     'CLOSE' GreyImage
  70.   end
  71.   else OutputImage = GreyImage
  72.  
  73.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  74.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  75.   if (RC ~= 0) then do
  76.     'IE_TO_FRONT'
  77.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  78.     return '<ERROR>'
  79.   end
  80.   'CLOSE' OutputImage
  81.  
  82.   back = 'OK'
  83. return back
  84.  
  85. /* Internal procedures  ---------------------------------------------- */
  86.  
  87. /*******************************************************************/
  88. /* This is where control goes when an error code is returned by IE */
  89. /* It puts up a message saying what happened and on which line     */
  90. /*******************************************************************/
  91.  
  92. error:
  93. if RC=5 then do
  94.     IE_TO_FRONT
  95.     LAST_ERROR
  96.     'REQUEST "'||RESULT||'"'
  97. end
  98. else do
  99.     IE_TO_FRONT
  100.     LAST_ERROR
  101.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  102. end
  103.  
  104. return '<ERROR>'
  105.